<!DOCTYPE html>
<!--
Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/dashboard/elements/chart-title.html">
<link rel="import" href="/dashboard/static/testing_common.html">
<link rel="import" href="/tracing/core/test_utils.html">

<script>
'use strict';

tr.b.unittest.testSuite(function() {
  const testOptions = {
    setUp() {
    },
    tearDown() {
    }
  };

  test('instantiate basic', function() {
    const title = document.createElement('chart-title');
    title.testSuites = {
      'dromaeo': {'des': 'Description of dromaeo.'},
      'sunspider': {'des': 'Sunspider test.'}
    };
    title.seriesGroupList = [{
      'path': 'ChromiumPerf/win/dromaeo/dom/Total',
      'tests': [{'name': 'Total'}]
    }];
    title.update();
    this.addHTMLOutput(title);
  }, testOptions);

  test('after update is called, suite descriptions are set', function() {
    const title = document.createElement('chart-title');
    title.testSuites = {
      'dromaeo': {'des': 'Description of dromaeo.'},
      'sunspider': {'des': 'Sunspider test.'}
    };
    title.seriesGroupList = [
      {
        'path': 'ChromiumPerf/win/dromaeo',
        'tests': [{'name': 'Total'}]
      },
      {
        'path': 'ChromiumPerf/win/somestuff',
        'tests': [{'name': 'Total'}]
      },
      {
        'path': 'ChromiumPerf/win/sunspider',
        'tests': [{'name': 'Total'}]
      }];
    title.update();
    this.addHTMLOutput(title);
    assert.propertyVal(
        title.suiteDescriptions[0], 'description', 'Description of dromaeo.');
    assert.propertyVal(
        title.suiteDescriptions[1], 'description', 'Sunspider test.');
    assert.lengthOf(title.suiteDescriptions, 2);
  }, testOptions);
});
</script>
